home *** CD-ROM | disk | FTP | other *** search
/ ShareWare OnLine 2 / ShareWare OnLine Volume 2 (CMS Software)(1993).iso / graphics / manythng.zip / BACKGRND.FRM next >
Text File  |  1993-04-15  |  42KB  |  1,506 lines

  1. VERSION 2.00
  2. Begin Form BackGround 
  3.    BackColor       =   &H00000000&
  4.    BorderStyle     =   0  'None
  5.    ControlBox      =   0   'False
  6.    Height          =   2976
  7.    Icon            =   BACKGRND.FRX:0000
  8.    Left            =   864
  9.    LinkTopic       =   "Form1"
  10.    ScaleHeight     =   213
  11.    ScaleMode       =   3  'Pixel
  12.    ScaleWidth      =   478
  13.    Top             =   1260
  14.    Width           =   5832
  15.    Begin Timer Tick 
  16.       Interval        =   50
  17.       Left            =   10
  18.       Top             =   10
  19.    End
  20. End
  21. ' BackGround -- this form expands to fill the whole
  22. '   screen and is used as the back drop for all the
  23. '   drawing
  24.  
  25. Option Explicit
  26.  
  27. ' variables declared here
  28. Dim lastX, lastY            ' Last position of the moves
  29. Dim LastTime As Long
  30. Dim CurrentTime As Long
  31. Dim LinkTime As Long
  32. Dim PlotType As Integer
  33. Dim PlotInit As Integer
  34. Dim RepeatIndex As Integer
  35. Dim Pointer As Integer
  36. Dim Mirror As Integer
  37. Dim x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer
  38. Dim vx1 As Single, vy1 As Single, vx2 As Single, vy2 As Single
  39. Dim ax1 As Single, ax2 As Single, ay1 As Single, ay2 As Single
  40. Dim l As Long
  41. Dim m As Long
  42. Dim MaxSpeedX As Integer, MaxSpeedY As Integer
  43. Dim TimeInterval As Long
  44. Dim MaxTime As Long
  45. Dim Repeats As Integer
  46. Dim i As Integer
  47. Dim BoxHeight As Integer, BoxWidth As Integer
  48. Dim DC As Integer
  49. Dim Pattern As Long, Locked As Integer
  50. Dim Direction As Integer
  51.  
  52. 'Allocate Memory
  53. Dim x1a() As Integer
  54. Dim x2a() As Integer
  55. Dim y1a() As Integer
  56. Dim y2a() As Integer
  57. Dim x1da() As Integer
  58. Dim x2da() As Integer
  59. Dim y1da() As Integer
  60. Dim y2da() As Integer
  61. Dim x1sa() As Single
  62. Dim x2sa() As Single
  63. Dim y1sa() As Single
  64. Dim y2sa() As Single
  65. Dim vx1sa() As Single
  66. Dim vx2sa() As Single
  67. Dim vy1sa() As Single
  68. Dim vy2sa() As Single
  69. Dim ax1sa() As Single
  70. Dim ax2sa() As Single
  71. Dim ay1sa() As Single
  72. Dim ay2sa() As Single
  73. Dim Colors() As Long
  74. Dim DataPts() As Integer
  75.  
  76. Dim MaxPlotType As Integer
  77.  
  78. Sub Circles ()
  79.   
  80.   ' have a single elipse trace across the
  81.   ' screen with multiple previous copies following
  82.   ' it
  83.  
  84.   Dim i As Integer, j As Integer, k As Integer, N As Integer
  85.   Dim xRadius As Integer, yRadius As Integer
  86.  
  87.   ' if first time then initialize
  88.   If PlotInit = False Then
  89.     
  90.     PlotInit = True
  91.     Cls
  92.     Forecolor = QBColor(15)
  93.  
  94.     'Set array size and clear the elements
  95.     ReDim x1a(MaxLines) As Integer
  96.     ReDim x2a(MaxLines) As Integer
  97.     ReDim y1a(MaxLines) As Integer
  98.     ReDim y2a(MaxLines) As Integer
  99.  
  100.     Pointer = 1     ' start with array element 1
  101.     
  102.     ' set index to count number of times to repeat color
  103.     '   to past maxvalue so that it will be recalculated
  104.     RepeatIndex = MaxLines + 1
  105.  
  106.     'determine initial position of line
  107.     x1 = Rnd * ScaleWidth
  108.     x2 = Rnd * ScaleWidth
  109.     y1 = Rnd * ScaleHeight
  110.     y2 = Rnd * ScaleHeight
  111.  
  112.     'set initial velocity
  113.     vx1 = 0
  114.     vx2 = 0
  115.     vy1 = 0
  116.     vy2 = 0
  117.  
  118.     'set initial acceleration
  119.     ax1 = 0
  120.     ax2 = 0
  121.     ay1 = 0
  122.     ay2 = 0
  123.     
  124.     'find background color
  125.     m = QBColor(0)
  126.  
  127.     'Calculate velocity limits
  128.     MaxSpeedX = ScaleWidth * 15! / 800
  129.     MaxSpeedY = ScaleWidth * 15! / 600
  130.  
  131.  
  132.   Else  ' put run code here
  133.  
  134.  
  135.     ' check if time to get a new color
  136.     If RepeatIndex > RepeatCount Then
  137.     
  138.         ' use rgb function
  139.         i = Rnd * 255: If i > 255 Then i = 255
  140.         j = Rnd * 255: If j > 255 Then j = 255
  141.         k = Rnd * 255: If k > 255 Then k = 255
  142.         l = RGB(i, j, k)
  143.  
  144.         RepeatIndex = 1
  145.     Else
  146.         RepeatIndex = RepeatIndex + 1
  147.     End If
  148.  
  149.         'Delete original circle
  150.         xRadius = Abs(x1a(Pointer) - x2a(Pointer)) / 2
  151.         yRadius = Abs(y1a(Pointer) - y2a(Pointer)) / 2
  152.         If xRadius <> 0 Then
  153.             Circle ((x1a(Pointer) + x2a(Pointer)) / 2, (y1a(Pointer) + y2a(Pointer)) / 2), xRadius, m, , , yRadius / xRadius
  154.         End If
  155.  
  156.         'Save New Circle
  157.         x1a(Pointer) = x1
  158.         x2a(Pointer) = x2
  159.         y1a(Pointer) = y1
  160.         y2a(Pointer) = y2
  161.  
  162.         'Draw new Circle
  163.         xRadius = Abs(x1a(Pointer) - x2a(Pointer)) / 2
  164.         yRadius = Abs(y1a(Pointer) - y2a(Pointer)) / 2
  165.         If xRadius <> 0 Then
  166.             Circle ((x1a(Pointer) + x2a(Pointer)) / 2, (y1a(Pointer) + y2a(Pointer)) / 2), xRadius, l, , , yRadius / xRadius
  167.         End If
  168.  
  169.         'Move pointer to next item
  170.         Pointer = Pointer + 1
  171.         If Pointer > MaxLines Then
  172.             Pointer = 1
  173.         End If
  174.  
  175.         'determine new acceleration
  176.         ax1 = Rnd - .5
  177.         ax2 = Rnd - .5
  178.         ay1 = Rnd - .5
  179.         ay2 = Rnd - .5
  180.  
  181.         'calculate new position
  182.         x1 = x1 + vx1
  183.         x2 = x2 + vx2
  184.         y1 = y1 + vy1
  185.         y2 = y2 + vy2
  186.  
  187.         'calculate new velocity
  188.         vx1 = (vx1 + ax1): If Abs(vx1) > MaxSpeedX Then vx1 = 0: ax1 = 0
  189.         vx2 = (vx2 + ax2): If Abs(vx2) > MaxSpeedX Then vx2 = 0: ax2 = 0
  190.         vy1 = (vy1 + ay1): If Abs(vy1) > MaxSpeedY Then vy1 = 0: ay1 = 0
  191.         vy2 = (vy2 + ay2): If Abs(vy2) > MaxSpeedY Then vy2 = 0: ay2 = 0
  192.  
  193.         'check if off screen
  194.         If (x1 > ScaleWidth) Then
  195.             'change direction
  196.             vx1 = -Abs(vx1)
  197.         ElseIf (x1 < 0) Then
  198.             'change direction
  199.             vx1 = Abs(vx1)
  200.         End If
  201.  
  202.         If (y1 > ScaleHeight) Then
  203.             'change direction
  204.             vy1 = -Abs(vy1)
  205.         ElseIf (y1 < 0) Then
  206.             'change direction
  207.             vy1 = Abs(vy1)
  208.         End If
  209.  
  210.         If (x2 > ScaleWidth) Then
  211.             'change direction
  212.             vx2 = -Abs(vx2)
  213.         ElseIf (x2 < 0) Then
  214.             'change direction
  215.             vx2 = Abs(vx2)
  216.         End If
  217.  
  218.         If (y2 > ScaleHeight) Then
  219.             'change direction
  220.             vy2 = -Abs(vy2)
  221.         ElseIf (y2 < 0) Then
  222.             'change direction
  223.             vy2 = Abs(vy2)
  224.         End If
  225.  
  226.  
  227.   End If
  228.  
  229. End Sub
  230.  
  231. Sub ClearArrays ()
  232.  
  233.         'clear arrays
  234.         ReDim x1a(0) As Integer
  235.         ReDim x2a(0) As Integer
  236.         ReDim y1a(0) As Integer
  237.         ReDim y2a(0) As Integer
  238.         ReDim x1da(0, 0) As Integer
  239.         ReDim x2da(0, 0) As Integer
  240.         ReDim y1da(0, 0) As Integer
  241.         ReDim y2da(0, 0) As Integer
  242.         ReDim x1sa(0) As Single
  243.         ReDim x2sa(0) As Single
  244.         ReDim y1sa(0) As Single
  245.         ReDim y2sa(0) As Single
  246.         ReDim vx1sa(0) As Single
  247.         ReDim vx2sa(0) As Single
  248.         ReDim vy1sa(0) As Single
  249.         ReDim vy2sa(0) As Single
  250.         ReDim ax1sa(0) As Single
  251.         ReDim ax2sa(0) As Single
  252.         ReDim ay1sa(0) As Single
  253.         ReDim ay2sa(0) As Single
  254.         ReDim Colors(0) As Long
  255.     
  256.  
  257.  
  258. End Sub
  259.  
  260. Sub Form_KeyDown (KeyCode As Integer, Shift As Integer)
  261.     EndScrnsave                 ' End screen blanking
  262. End Sub
  263.  
  264. Sub Form_Load ()
  265.  
  266.     ' stretch to full screen
  267.     Move 0, 0, Screen.Width, Screen.Height
  268.     
  269.     DrawWidth = 1
  270.  
  271.     'For i = 1 To 10: l = Rnd: Next i' clear first values from Rnd
  272.     Randomize
  273.  
  274.     ' Initialize variables now
  275.     MaxPlotType = 12
  276.     PlotType = Rnd * (MaxPlotType + 1)' choose random start place
  277.     'PlotType = 8 ' fixed start place
  278.     If PlotType > MaxPlotType Then PlotType = 0
  279.  
  280.     PlotInit = False
  281.     TimeInterval = 0
  282.     MaxTime = MaxChangeMinutes * 60 + Timer ' calculate time in seconds
  283.  
  284.     HideMouse
  285.  
  286.     Repeats = 1 ' number of drawings to make before returning
  287.  
  288. End Sub
  289.  
  290. Sub Form_MouseMove (Button As Integer, Shift As Integer, x As Single, y As Single)
  291.     If IsEmpty(lastX) Or IsEmpty(lastY) Then
  292.         lastX = x
  293.         lastY = y
  294.     End If
  295.  
  296.     '
  297.     ' Only unblank the screen if the mouse moves quickly
  298.     ' enough (more than 2 pixels at one time.
  299.     '
  300.     If Abs(lastX - x) > 2 Or Abs(lastY - y) > 2 Then
  301.         EndScrnsave             ' End screen blanking
  302.     End If
  303.     lastX = x                   ' Remember last position
  304.     lastY = y
  305. End Sub
  306.  
  307. Sub Kalied ()
  308.   
  309.   ' have a line and its mirror images trace across the
  310.   ' screen with multiple previous copies following
  311.   ' it
  312.  
  313.   Dim i As Integer, j As Integer, k As Integer, N As Integer
  314.   Dim xRadius As Integer, yRadius As Integer
  315.   Dim HighMirror As Integer
  316.  
  317.   ' if first time then initialize
  318.   If PlotInit = False Then
  319.     
  320.     PlotInit = True
  321.     Cls
  322.     Forecolor = QBColor(15)
  323.  
  324.     'select mirroring method
  325.     HighMirror = 3
  326.     Mirror = Rnd * HighMirror + 1: If Mirror > HighMirror Then Mirror = 1
  327.  
  328.     'Set array size and clear the elements
  329.     ReDim x1a(MaxLines) As Integer
  330.     ReDim x2a(MaxLines) As Integer
  331.     ReDim y1a(MaxLines) As Integer
  332.     ReDim y2a(MaxLines) As Integer
  333.  
  334.     Pointer = 1     ' start with array element 1
  335.     
  336.     ' set index to count number of times to repeat color
  337.     '   to past maxvalue so that it will be recalculated
  338.     RepeatIndex = MaxLines + 1
  339.  
  340.     'determine initial position of line
  341.     x1 = Rnd * ScaleWidth
  342.     x2 = Rnd * ScaleWidth
  343.     y1 = Rnd * ScaleHeight
  344.     y2 = Rnd * ScaleHeight
  345.  
  346.     'set initial velocity
  347.     vx1 = 0
  348.     vx2 = 0
  349.     vy1 = 0
  350.     vy2 = 0
  351.  
  352.     'set initial acceleration
  353.     ax1 = 0
  354.     ax2 = 0
  355.     ay1 = 0
  356.     ay2 = 0
  357.     
  358.     'find background color
  359.     m = QBColor(0)
  360.  
  361.     'Calculate velocity limits
  362.     MaxSpeedX = ScaleWidth * 15! / 800
  363.     MaxSpeedY = ScaleWidth * 15! / 600
  364.  
  365.  
  366.   Else  ' put run code here
  367.  
  368.  
  369.     ' check if time to get a new color
  370.     If RepeatIndex > RepeatCount Then
  371.     
  372.         ' use rgb function
  373.         i = Rnd * 255: If i > 255 Then i = 255
  374.         j = Rnd * 255: If j > 255 Then j = 255
  375.         k = Rnd * 255: If k > 255 Then k = 255
  376.         l = RGB(i, j, k)
  377.  
  378.         RepeatIndex = 1
  379.     Else
  380.         RepeatIndex = RepeatIndex + 1
  381.     End If
  382.  
  383.         'Delete original Lines
  384.         Select Case Mirror
  385.         Case 1: 'mirror on x and y axis
  386.             Line (x1a(Pointer), y1a(Pointer))-(x2a(Pointer), y2a(Pointer)), m
  387.             Line (ScaleWidth - x1a(Pointer), y1a(Pointer))-(ScaleWidth - x2a(Pointer), y2a(Pointer)), m
  388.             Line (x1a(Pointer), ScaleHeight - y1a(Pointer))-(x2a(Pointer), ScaleHeight - y2a(Pointer)), m
  389.             Line (ScaleWidth - x1a(Pointer), ScaleHeight - y1a(Pointer))-(ScaleWidth - x2a(Pointer), ScaleHeight - y2a(Pointer)), m
  390.  
  391.         Case 2: 'mirror on Y axis
  392.             Line (x1a(Pointer), y1a(Pointer))-(x2a(Pointer), y2a(Pointer)), m
  393.             Line (ScaleWidth - x1a(Pointer), y1a(Pointer))-(ScaleWidth - x2a(Pointer), y2a(Pointer)), m
  394.  
  395.         Case 3: 'mirror around center point
  396.             Line (x1a(Pointer), y1a(Pointer))-(x2a(Pointer), y2a(Pointer)), m
  397.             Line (ScaleWidth - x1a(Pointer), ScaleHeight - y1a(Pointer))-(ScaleWidth - x2a(Pointer), ScaleHeight - y2a(Pointer)), m
  398.  
  399.         Case Else: Mirror = 1' if invalid value set, then change
  400.         
  401.         End Select
  402.  
  403.         'Save New Lines
  404.         x1a(Pointer) = x1
  405.         x2a(Pointer) = x2
  406.         y1a(Pointer) = y1
  407.         y2a(Pointer) = y2
  408.  
  409.         'Draw New Lines
  410.         Select Case Mirror
  411.         Case 1: 'mirror on x and y axis
  412.             Line (x1a(Pointer), y1a(Pointer))-(x2a(Pointer), y2a(Pointer)), l
  413.             Line (ScaleWidth - x1a(Pointer), y1a(Pointer))-(ScaleWidth - x2a(Pointer), y2a(Pointer)), l
  414.             Line (x1a(Pointer), ScaleHeight - y1a(Pointer))-(x2a(Pointer), ScaleHeight - y2a(Pointer)), l
  415.             Line (ScaleWidth - x1a(Pointer), ScaleHeight - y1a(Pointer))-(ScaleWidth - x2a(Pointer), ScaleHeight - y2a(Pointer)), l
  416.  
  417.         Case 2: 'mirror on Y axis
  418.             Line (x1a(Pointer), y1a(Pointer))-(x2a(Pointer), y2a(Pointer)), l
  419.             Line (ScaleWidth - x1a(Pointer), y1a(Pointer))-(ScaleWidth - x2a(Pointer), y2a(Pointer)), l
  420.  
  421.         Case 3: 'mirror around center point
  422.             Line (x1a(Pointer), y1a(Pointer))-(x2a(Pointer), y2a(Pointer)), l
  423.             Line (ScaleWidth - x1a(Pointer), ScaleHeight - y1a(Pointer))-(ScaleWidth - x2a(Pointer), ScaleHeight - y2a(Pointer)), l
  424.  
  425.         Case Else: Mirror = 1' if invalid value set, then change
  426.         
  427.         End Select
  428.  
  429.         'Move pointer to next item
  430.         Pointer = Pointer + 1
  431.         If Pointer > MaxLines Then
  432.             Pointer = 1
  433.         End If
  434.  
  435.         'determine new acceleration
  436.         ax1 = Rnd - .5
  437.         ax2 = Rnd - .5
  438.         ay1 = Rnd - .5
  439.         ay2 = Rnd - .5
  440.  
  441.         'calculate new position
  442.         x1 = x1 + vx1
  443.         x2 = x2 + vx2
  444.         y1 = y1 + vy1
  445.         y2 = y2 + vy2
  446.  
  447.         'calculate new velocity
  448.         vx1 = (vx1 + ax1): If Abs(vx1) > MaxSpeedX Then vx1 = 0: ax1 = 0
  449.         vx2 = (vx2 + ax2): If Abs(vx2) > MaxSpeedX Then vx2 = 0: ax2 = 0
  450.         vy1 = (vy1 + ay1): If Abs(vy1) > MaxSpeedY Then vy1 = 0: ay1 = 0
  451.         vy2 = (vy2 + ay2): If Abs(vy2) > MaxSpeedY Then vy2 = 0: ay2 = 0
  452.  
  453.         'check if off screen
  454.         If (x1 > ScaleWidth) Then
  455.             'change direction
  456.             vx1 = -Abs(vx1)
  457.         ElseIf (x1 < 0) Then
  458.             'change direction
  459.             vx1 = Abs(vx1)
  460.         End If
  461.  
  462.         If (y1 > ScaleHeight) Then
  463.             'change direction
  464.             vy1 = -Abs(vy1)
  465.         ElseIf (y1 < 0) Then
  466.             'change direction
  467.             vy1 = Abs(vy1)
  468.         End If
  469.  
  470.         If (x2 > ScaleWidth) Then
  471.             'change direction
  472.             vx2 = -Abs(vx2)
  473.         ElseIf (x2 < 0) Then
  474.             'change direction
  475.             vx2 = Abs(vx2)
  476.         End If
  477.  
  478.         If (y2 > ScaleHeight) Then
  479.             'change direction
  480.             vy2 = -Abs(vy2)
  481.         ElseIf (y2 < 0) Then
  482.             'change direction
  483.             vy2 = Abs(vy2)
  484.         End If
  485.  
  486.     
  487.     End If
  488.  
  489. End Sub
  490.  
  491. Sub Kalied2 ()
  492.   
  493.   ' have a line and its mirror images trace across the
  494.   ' screen with all the previous copies left on the screen
  495.   ' until the maximum is reached and the screen cleared
  496.  
  497.   Dim i As Integer, j As Integer, k As Integer, N As Integer
  498.   Dim xRadius As Integer, yRadius As Integer
  499.   Dim HighMirror As Integer
  500.  
  501.   ' if first time then initialize
  502.   If PlotInit = False Then
  503.     
  504.     PlotInit = True
  505.     Cls
  506.     Forecolor = QBColor(15)
  507.  
  508.     'select mirroring method
  509.     HighMirror = 3
  510.     Mirror = Rnd * HighMirror + 1: If Mirror > HighMirror Then Mirror = 1
  511.  
  512.     Pointer = 1     ' set lines on screen to one
  513.     
  514.     ' set index to count number of times to repeat color
  515.     '   to past maxvalue so that it will be recalculated
  516.     RepeatIndex = MaxLines + 1
  517.  
  518.     'determine initial position of line
  519.     x1 = Rnd * ScaleWidth
  520.     x2 = Rnd * ScaleWidth
  521.     y1 = Rnd * ScaleHeight
  522.     y2 = Rnd * ScaleHeight
  523.  
  524.     'set initial velocity
  525.     vx1 = 0
  526.     vx2 = 0
  527.     vy1 = 0
  528.     vy2 = 0
  529.  
  530.     'set initial acceleration
  531.     ax1 = 0
  532.     ax2 = 0
  533.     ay1 = 0
  534.     ay2 = 0
  535.     
  536.     'find background color
  537.     m = QBColor(0)
  538.  
  539.     'Calculate velocity limits
  540.     MaxSpeedX = ScaleWidth * 15! / 800
  541.     MaxSpeedY = ScaleWidth * 15! / 600
  542.  
  543.  
  544.   Else  ' put run code here
  545.  
  546.  
  547.     ' check if time to get a new color
  548.     If RepeatIndex > RepeatCount Then
  549.     
  550.         ' use rgb function
  551.         i = Rnd * 255: If i > 255 Then i = 255
  552.         j = Rnd * 255: If j > 255 Then j = 255
  553.         k = Rnd * 255: If k > 255 Then k = 255
  554.         l = RGB(i, j, k)
  555.  
  556.         RepeatIndex = 1
  557.     Else
  558.         RepeatIndex = RepeatIndex + 1
  559.     End If
  560.  
  561.         'Draw New Lines
  562.         Select Case Mirror
  563.         Case 1: 'mirror on x and y axis
  564.             Line (x1, y1)-(x2, y2), l
  565.             Line (ScaleWidth - x1, y1)-(ScaleWidth - x2, y2), l
  566.             Line (x1, ScaleHeight - y1)-(x2, ScaleHeight - y2), l
  567.             Line (ScaleWidth - x1, ScaleHeight - y1)-(ScaleWidth - x2, ScaleHeight - y2), l
  568.  
  569.         Case 2: 'mirror on Y axis
  570.             Line (x1, y1)-(x2, y2), l
  571.             Line (ScaleWidth - x1, y1)-(ScaleWidth - x2, y2), l
  572.  
  573.         Case 3: 'mirror around center point
  574.             Line (x1, y1)-(x2, y2), l
  575.             Line (ScaleWidth - x1, ScaleHeight - y1)-(ScaleWidth - x2, ScaleHeight - y2), l
  576.         
  577.         Case Else: Mirror = 1' if invalid value set, then change
  578.         
  579.         End Select
  580.  
  581.         ' count total lines on screen
  582.         Pointer = Pointer + 1
  583.         If Pointer > MaxCums Then
  584.             'when maximum reached then clear
  585.             Cls
  586.             Pointer = 1
  587.         End If
  588.  
  589.         'determine new acceleration
  590.         ax1 = Rnd - .5
  591.         ax2 = Rnd - .5
  592.         ay1 = Rnd - .5
  593.         ay2 = Rnd - .5
  594.  
  595.         'calculate new position
  596.         x1 = x1 + vx1
  597.         x2 = x2 + vx2
  598.         y1 = y1 + vy1
  599.         y2 = y2 + vy2
  600.  
  601.         'calculate new velocity
  602.         vx1 = (vx1 + ax1): If Abs(vx1) > MaxSpeedX Then vx1 = 0: ax1 = 0
  603.         vx2 = (vx2 + ax2): If Abs(vx2) > MaxSpeedX Then vx2 = 0: ax2 = 0
  604.         vy1 = (vy1 + ay1): If Abs(vy1) > MaxSpeedY Then vy1 = 0: ay1 = 0
  605.         vy2 = (vy2 + ay2): If Abs(vy2) > MaxSpeedY Then vy2 = 0: ay2 = 0
  606.  
  607.         'check if off screen
  608.         If (x1 > ScaleWidth) Then
  609.             'change direction
  610.             vx1 = -Abs(vx1)
  611.         ElseIf (x1 < 0) Then
  612.             'change direction
  613.             vx1 = Abs(vx1)
  614.         End If
  615.  
  616.         If (y1 > ScaleHeight) Then
  617.             'change direction
  618.             vy1 = -Abs(vy1)
  619.         ElseIf (y1 < 0) Then
  620.             'change direction
  621.             vy1 = Abs(vy1)
  622.         End If
  623.  
  624.         If (x2 > ScaleWidth) Then
  625.             'change direction
  626.             vx2 = -Abs(vx2)
  627.         ElseIf (x2 < 0) Then
  628.             'change direction
  629.             vx2 = Abs(vx2)
  630.         End If
  631.  
  632.         If (y2 > ScaleHeight) Then
  633.             'change direction
  634.             vy2 = -Abs(vy2)
  635.         ElseIf (y2 < 0) Then
  636.             'change direction
  637.             vy2 = Abs(vy2)
  638.         End If
  639.  
  640.     
  641.     End If
  642.  
  643.  
  644. End Sub
  645.  
  646. Sub Lines ()
  647.  
  648.   ' have a random number of lines trace across the
  649.   ' screen with multiple previous copies following
  650.   ' them
  651.  
  652.   Dim i As Integer, j As Integer, k As Integer, ii As Integer, N As Integer
  653.   Static Sets As Integer
  654.   
  655.   ' if first time then initialize
  656.   If PlotInit = False Then
  657.     
  658.     PlotInit = True
  659.     Cls
  660.     Forecolor = QBColor(15)
  661.  
  662.     'set number of sets between 1 and 4
  663.     Sets = Rnd * 3 + 1
  664.  
  665.     'Set array size and clear the elements
  666.     ReDim x1da(MaxLines, Sets) As Integer
  667.     ReDim x2da(MaxLines, Sets) As Integer
  668.     ReDim y1da(MaxLines, Sets) As Integer
  669.     ReDim y2da(MaxLines, Sets) As Integer
  670.     ReDim x1sa(Sets) As Single
  671.     ReDim x2sa(Sets) As Single
  672.     ReDim y1sa(Sets) As Single
  673.     ReDim y2sa(Sets) As Single
  674.     ReDim vx1sa(Sets) As Single
  675.     ReDim vx2sa(Sets) As Single
  676.     ReDim vy1sa(Sets) As Single
  677.     ReDim vy2sa(Sets) As Single
  678.     ReDim ax1sa(Sets) As Single
  679.     ReDim ax2sa(Sets) As Single
  680.     ReDim ay1sa(Sets) As Single
  681.     ReDim ay2sa(Sets) As Single
  682.     ReDim Colors(Sets) As Long
  683.     
  684.     Pointer = 1     ' start with array element 1
  685.     
  686.     ' set index to count number of times to repeat color
  687.     '   to past maxvalue so that it will be recalculated
  688.     RepeatIndex = MaxLines + 1
  689.  
  690.     For j = 1 To Sets
  691.  
  692.         'determine initial position of line
  693.         x1sa(j) = Rnd * ScaleWidth
  694.         x2sa(j) = Rnd * ScaleWidth
  695.         y1sa(j) = Rnd * ScaleHeight
  696.         y2sa(j) = Rnd * ScaleHeight
  697.  
  698.     Next j
  699.     
  700.     'find background color
  701.     m = QBColor(0)
  702.  
  703.     'Calculate velocity limits
  704.     MaxSpeedX = ScaleWidth * 15! / 800
  705.     MaxSpeedY = ScaleWidth * 15! / 600
  706.  
  707.  
  708.   Else  ' put run code here
  709.  
  710.  
  711.     ' check if time to get a new color
  712.     If RepeatIndex > RepeatCount Then
  713.     
  714.         ' use rgb function
  715.         For ii = 1 To Sets
  716.             i = Rnd * 255: If i > 255 Then i = 255
  717.             j = Rnd * 255: If j > 255 Then j = 255
  718.             k = Rnd * 255: If k > 255 Then k = 255
  719.             Colors(ii) = RGB(i, j, k)
  720.         Next ii
  721.  
  722.         RepeatIndex = 1
  723.     Else
  724.         RepeatIndex = RepeatIndex + 1
  725.     End If
  726.  
  727.         'Delete original Lines
  728.         For j = 1 To Sets
  729.             Line (x1da(Pointer, j), y1da(Pointer, j))-(x2da(Pointer, j), y2da(Pointer, j)), m
  730.         Next j
  731.  
  732.         For j = 1 To Sets
  733.  
  734.             'Save New Lines
  735.             x1da(Pointer, j) = x1sa(j)
  736.             x2da(Pointer, j) = x2sa(j)
  737.             y1da(Pointer, j) = y1sa(j)
  738.             y2da(Pointer, j) = y2sa(j)
  739.  
  740.             'Draw new Line
  741.             Line (x1da(Pointer, j), y1da(Pointer, j))-(x2da(Pointer, j), y2da(Pointer, j)), Colors(j)
  742.  
  743.         Next j
  744.  
  745.         'Move pointer to next item
  746.         Pointer = Pointer + 1
  747.         If Pointer > MaxLines Then
  748.             Pointer = 1
  749.         End If
  750.  
  751.         For j = 1 To Sets
  752.  
  753.             'determine new acceleration
  754.             ax1sa(j) = Rnd - .5
  755.             ax2sa(j) = Rnd - .5
  756.             ay1sa(j) = Rnd - .5
  757.             ay2sa(j) = Rnd - .5
  758.  
  759.             'calculate new position
  760.             x1sa(j) = x1sa(j) + vx1sa(j)
  761.             x2sa(j) = x2sa(j) + vx2sa(j)
  762.             y1sa(j) = y1sa(j) + vy1sa(j)
  763.             y2sa(j) = y2sa(j) + vy2sa(j)
  764.  
  765.             'calculate new velocity
  766.             vx1sa(j) = (vx1sa(j) + ax1sa(j)): If Abs(vx1sa(j)) > MaxSpeedX Then vx1sa(j) = 0: ax1sa(j) = 0
  767.             vx2sa(j) = (vx2sa(j) + ax2sa(j)): If Abs(vx2sa(j)) > MaxSpeedX Then vx2sa(j) = 0: ax2sa(j) = 0
  768.             vy1sa(j) = (vy1sa(j) + ay1sa(j)): If Abs(vy1sa(j)) > MaxSpeedY Then vy1sa(j) = 0: ay1sa(j) = 0
  769.             vy2sa(j) = (vy2sa(j) + ay2sa(j)): If Abs(vy2sa(j)) > MaxSpeedY Then vy2sa(j) = 0: ay2sa(j) = 0
  770.  
  771.             'check if off screen
  772.             If (x1sa(j) > ScaleWidth) Then
  773.                 'change direction
  774.                 vx1sa(j) = -Abs(vx1sa(j))
  775.             ElseIf (x1sa(j) < 0) Then
  776.                 'change direction
  777.                 vx1sa(j) = Abs(vx1sa(j))
  778.             End If
  779.  
  780.             If (y1sa(j) > ScaleHeight) Then
  781.                 'change direction
  782.                 vy1sa(j) = -Abs(vy1sa(j))
  783.             ElseIf (y1sa(j) < 0) Then
  784.                 'change direction
  785.                 vy1sa(j) = Abs(vy1sa(j))
  786.             End If
  787.  
  788.             If (x2sa(j) > ScaleWidth) Then
  789.                 'change direction
  790.                 vx2sa(j) = -Abs(vx2sa(j))
  791.             ElseIf (x2sa(j) < 0) Then
  792.                 'change direction
  793.                 vx2sa(j) = Abs(vx2sa(j))
  794.             End If
  795.  
  796.             If (y2sa(j) > ScaleHeight) Then
  797.                 'change direction
  798.                 vy2sa(j) = -Abs(vy2sa(j))
  799.             ElseIf (y2sa(j) < 0) Then
  800.                 'change direction
  801.                 vy2sa(j) = Abs(vy2sa(j))
  802.             End If
  803.  
  804.         Next j
  805.     
  806.     
  807.   End If
  808.  
  809. End Sub
  810.  
  811. Sub Patch ()
  812.  
  813.   ' copy blocks of original screen to random spots
  814.  
  815.   ' if first time then initialize
  816.   If PlotInit = False Then
  817.     
  818.     ' set tick rate down
  819.     Tick.Interval = 250
  820.  
  821.     ' start with original screen
  822.     Picture = Original.Image
  823.     
  824.     PlotInit = True
  825.  
  826.   Else  ' put run code here
  827.  
  828.     BoxHeight = Rnd * ScaleHeight / 2.5
  829.     BoxWidth = Rnd * ScaleWidth / 2.5 * (8# / 6#)
  830.  
  831.     ' get random locations
  832.     x1 = Rnd * ScaleWidth
  833.     y1 = Rnd * ScaleHeight
  834.     x2 = Rnd * ScaleWidth
  835.     y2 = Rnd * ScaleHeight
  836.  
  837.     'make sure room in destination and source blocks
  838.     If x1 + BoxWidth > ScaleWidth Then BoxWidth = ScaleWidth - x1
  839.     If x2 + BoxWidth > ScaleWidth Then BoxWidth = ScaleWidth - x2
  840.     If y1 + BoxHeight > ScaleHeight Then BoxHeight = ScaleHeight - y1
  841.     If y2 + BoxHeight > ScaleHeight Then BoxHeight = ScaleHeight - y2
  842.  
  843.     'BitBlt Box from x2,y2 to x1,y1
  844.     DC = Original.hDC
  845.     BitBlt hDC, x1, y1, BoxWidth, BoxHeight, DC, x2, y2, &HCC0020
  846.         
  847.   End If
  848.  
  849. End Sub
  850.  
  851. Sub Polygons ()
  852.  
  853.   ' draw a randomly moving polygon on the screen
  854.   ' with multiple previous copies following it
  855.  
  856.   Dim i As Integer, j As Integer, k As Integer, ii As Integer, N As Integer
  857.   Static Sets As Integer
  858.   
  859.   ' if first time then initialize
  860.   If PlotInit = False Then
  861.     
  862.     PlotInit = True
  863.     Cls
  864.     Forecolor = QBColor(15)
  865.  
  866.     'set number of sets between 3 and 5
  867.     Sets = Rnd * 2 + 3
  868.  
  869.     'Set array size and clear the elements
  870.     ReDim x1da(MaxLines, Sets) As Integer
  871.     ReDim y1da(MaxLines, Sets) As Integer
  872.     ReDim x1sa(Sets) As Single
  873.     ReDim y1sa(Sets) As Single
  874.     ReDim vx1sa(Sets) As Single
  875.     ReDim vy1sa(Sets) As Single
  876.     ReDim ax1sa(Sets) As Single
  877.     ReDim ay1sa(Sets) As Single
  878.     
  879.     Pointer = 1     ' start with array element 1
  880.     
  881.     ' set index to count number of times to repeat color
  882.     '   to past maxvalue so that it will be recalculated
  883.     RepeatIndex = MaxLines + 1
  884.  
  885.     For j = 1 To Sets
  886.  
  887.         'determine initial position of line
  888.         x1sa(j) = Rnd * ScaleWidth
  889.         y1sa(j) = Rnd * ScaleHeight
  890.  
  891.     Next j
  892.     
  893.     'find background color
  894.     m = QBColor(0)
  895.  
  896.     'Calculate velocity limits
  897.     MaxSpeedX = ScaleWidth * 15! / 800
  898.     MaxSpeedY = ScaleWidth * 15! / 600
  899.  
  900.  
  901.   Else  ' put run code here
  902.  
  903.  
  904.     ' check if time to get a new color
  905.     If RepeatIndex > RepeatCount Then
  906.     
  907.         i = Rnd * 255: If i > 255 Then i = 255
  908.         j = Rnd * 255: If j > 255 Then j = 255
  909.         k = Rnd * 255: If k > 255 Then k = 255
  910.         l = RGB(i, j, k)
  911.         
  912.         RepeatIndex = 1
  913.     Else
  914.         RepeatIndex = RepeatIndex + 1
  915.     End If
  916.  
  917.         'Delete original Lines
  918.         Line (x1da(Pointer, 1), y1da(Pointer, 1))-(x1da(Pointer, 2), y1da(Pointer, 2)), m
  919.         For j = 3 To Sets
  920.             Line -(x1da(Pointer, j), y1da(Pointer, j)), m
  921.         Next j
  922.         Line -(x1da(Pointer, 1), y1da(Pointer, 1)), m
  923.  
  924.         For j = 1 To Sets
  925.  
  926.             'Save New Lines
  927.             x1da(Pointer, j) = x1sa(j)
  928.             y1da(Pointer, j) = y1sa(j)
  929.  
  930.         Next j
  931.  
  932.         'Draw New Lines
  933.         Line (x1da(Pointer, 1), y1da(Pointer, 1))-(x1da(Pointer, 2), y1da(Pointer, 2)), l
  934.         For j = 3 To Sets
  935.             Line -(x1da(Pointer, j), y1da(Pointer, j)), l
  936.         Next j
  937.         Line -(x1da(Pointer, 1), y1da(Pointer, 1)), l
  938.  
  939.  
  940.         'Move pointer to next item
  941.         Pointer = Pointer + 1
  942.         If Pointer > MaxLines Then
  943.             Pointer = 1
  944.         End If
  945.  
  946.         For j = 1 To Sets
  947.  
  948.             'determine new acceleration
  949.             ax1sa(j) = Rnd - .5
  950.             ay1sa(j) = Rnd - .5
  951.             
  952.             'calculate new position
  953.             x1sa(j) = x1sa(j) + vx1sa(j)
  954.             y1sa(j) = y1sa(j) + vy1sa(j)
  955.  
  956.             'calculate new velocity
  957.             vx1sa(j) = (vx1sa(j) + ax1sa(j)): If Abs(vx1sa(j)) > MaxSpeedX Then vx1sa(j) = 0: ax1sa(j) = 0
  958.             vy1sa(j) = (vy1sa(j) + ay1sa(j)): If Abs(vy1sa(j)) > MaxSpeedY Then vy1sa(j) = 0: ay1sa(j) = 0
  959.  
  960.             'check if off screen
  961.             If (x1sa(j) > ScaleWidth) Then
  962.                 'change direction
  963.                 vx1sa(j) = -Abs(vx1sa(j))
  964.             ElseIf (x1sa(j) < 0) Then
  965.                 'change direction
  966.                 vx1sa(j) = Abs(vx1sa(j))
  967.             End If
  968.  
  969.             If (y1sa(j) > ScaleHeight) Then
  970.                 'change direction
  971.                 vy1sa(j) = -Abs(vy1sa(j))
  972.             ElseIf (y1sa(j) < 0) Then
  973.                 'change direction
  974.                 vy1sa(j) = Abs(vy1sa(j))
  975.             End If
  976.  
  977.         Next j
  978.     
  979.     End If
  980.  
  981. End Sub
  982.  
  983. Sub Puzzle ()
  984.  
  985.   'scramble screen by shifting one column or row at a time
  986.   
  987.   Dim tempx As Integer, tempy As Integer
  988.   Dim x As Integer, y As Integer
  989.  
  990.   ' if first time then initialize
  991.   If PlotInit = False Then
  992.     
  993.     ' set tick rate down
  994.     Tick.Interval = 1000
  995.  
  996.     ' start with original screen
  997.     Picture = Original.Image
  998.     
  999.     PlotInit = True
  1000.  
  1001.     BoxHeight = ScaleHeight / 10
  1002.     BoxWidth = ScaleWidth / 10
  1003.  
  1004.     'initialize blocks
  1005.     ReDim x1da(10, 10) As Integer
  1006.     ReDim y1da(10, 10) As Integer
  1007.     For x1 = 1 To 10
  1008.         For y1 = 1 To 10
  1009.             x1da(x1, y1) = (x1 - 1) * BoxWidth
  1010.             y1da(x1, y1) = (y1 - 1) * BoxHeight
  1011.         Next y1
  1012.     Next x1
  1013.  
  1014.   Else  ' put run code here
  1015.  
  1016.     If Int(Rnd * 2) = 1 Then 'shift column
  1017.         x1 = Rnd * 10 + 1: If x1 > 10 Then x1 = 1
  1018.         If Int(Rnd * 2) = 1 Then 'shift down
  1019.             tempx = x1da(x1, 10)
  1020.             tempy = y1da(x1, 10)
  1021.             For y1 = 10 To 2 Step -1
  1022.                 x1da(x1, y1) = x1da(x1, y1 - 1)
  1023.                 y1da(x1, y1) = y1da(x1, y1 - 1)
  1024.  
  1025.                 'BitBlt Box to x1,y1
  1026.                 DC = Original.hDC
  1027.                 x = (x1 - 1) * BoxWidth
  1028.                 y = (y1 - 1) * BoxHeight
  1029.                 BitBlt hDC, x, y, BoxWidth, BoxHeight, DC, x1da(x1, y1), y1da(x1, y1), &HCC0020
  1030.             Next y1
  1031.             y1 = 1
  1032.             x1da(x1, y1) = tempx
  1033.             y1da(x1, y1) = tempy
  1034.  
  1035.             'BitBlt Box to x1,y1
  1036.             DC = Original.hDC
  1037.             x = (x1 - 1) * BoxWidth
  1038.             y = (y1 - 1) * BoxHeight
  1039.             BitBlt hDC, x, y, BoxWidth, BoxHeight, DC, x1da(x1, y1), y1da(x1, y1), &HCC0020
  1040.  
  1041.         Else ' shift up
  1042.  
  1043.             tempx = x1da(x1, 1)
  1044.             tempy = y1da(x1, 1)
  1045.             For y1 = 1 To 9
  1046.                 x1da(x1, y1) = x1da(x1, y1 + 1)
  1047.                 y1da(x1, y1) = y1da(x1, y1 + 1)
  1048.  
  1049.                 'BitBlt Box to x1,y1
  1050.                 DC = Original.hDC
  1051.                 x = (x1 - 1) * BoxWidth
  1052.                 y = (y1 - 1) * BoxHeight
  1053.                 BitBlt hDC, x, y, BoxWidth, BoxHeight, DC, x1da(x1, y1), y1da(x1, y1), &HCC0020
  1054.             Next y1
  1055.             y1 = 10
  1056.             x1da(x1, y1) = tempx
  1057.             y1da(x1, y1) = tempy
  1058.  
  1059.             'BitBlt Box to x1,y1
  1060.             DC = Original.hDC
  1061.             x = (x1 - 1) * BoxWidth
  1062.             y = (y1 - 1) * BoxHeight
  1063.             BitBlt hDC, x, y, BoxWidth, BoxHeight, DC, x1da(x1, y1), y1da(x1, y1), &HCC0020
  1064.  
  1065.         End If
  1066.  
  1067.     Else ' shift row
  1068.         
  1069.         y1 = Rnd * 10 + 1: If y1 > 10 Then y1 = 1
  1070.         If Int(Rnd * 2) = 1 Then 'shift right
  1071.             tempx = x1da(10, y1)
  1072.             tempy = y1da(10, y1)
  1073.             For x1 = 10 To 2 Step -1
  1074.                 x1da(x1, y1) = x1da(x1 - 1, y1)
  1075.                 y1da(x1, y1) = y1da(x1 - 1, y1)
  1076.  
  1077.                 'BitBlt Box to x1,y1
  1078.                 DC = Original.hDC
  1079.                 x = (x1 - 1) * BoxWidth
  1080.                 y = (y1 - 1) * BoxHeight
  1081.                 BitBlt hDC, x, y, BoxWidth, BoxHeight, DC, x1da(x1, y1), y1da(x1, y1), &HCC0020
  1082.             Next x1
  1083.             x1 = 1
  1084.             x1da(x1, y1) = tempx
  1085.             y1da(x1, y1) = tempy
  1086.                 
  1087.             'BitBlt Box to x1,y1
  1088.             DC = Original.hDC
  1089.             x = (x1 - 1) * BoxWidth
  1090.             y = (y1 - 1) * BoxHeight
  1091.             BitBlt hDC, x, y, BoxWidth, BoxHeight, DC, x1da(x1, y1), y1da(x1, y1), &HCC0020
  1092.  
  1093.         Else 'shift left
  1094.  
  1095.             tempx = x1da(1, y1)
  1096.             tempy = y1da(1, y1)
  1097.             For x1 = 1 To 9
  1098.                 x1da(x1, y1) = x1da(x1 + 1, y1)
  1099.                 y1da(x1, y1) = y1da(x1 + 1, y1)
  1100.  
  1101.                 'BitBlt Box to x1,y1
  1102.                 DC = Original.hDC
  1103.                 x = (x1 - 1) * BoxWidth
  1104.                 y = (y1 - 1) * BoxHeight
  1105.                 BitBlt hDC, x, y, BoxWidth, BoxHeight, DC, x1da(x1, y1), y1da(x1, y1), &HCC0020
  1106.             Next x1
  1107.             x1 = 10
  1108.             x1da(x1, y1) = tempx
  1109.             y1da(x1, y1) = tempy
  1110.                 
  1111.             'BitBlt Box to x1,y1
  1112.             DC = Original.hDC
  1113.             x = (x1 - 1) * BoxWidth
  1114.             y = (y1 - 1) * BoxHeight
  1115.             BitBlt hDC, x, y, BoxWidth, BoxHeight, DC, x1da(x1, y1), y1da(x1, y1), &HCC0020
  1116.  
  1117.         End If
  1118.  
  1119.     End If
  1120.  
  1121.   End If
  1122.  
  1123.  
  1124. End Sub
  1125.  
  1126. Sub Roll ()
  1127.  
  1128.   ' the display rolls both horizontally and vertically
  1129.  
  1130.   Dim v As Integer
  1131.  
  1132.   ' if first time then initialize
  1133.   If PlotInit = False Then
  1134.     
  1135.     ' start with original screen
  1136.     Picture = Original.Image
  1137.  
  1138.     PlotInit = True
  1139.  
  1140.     'Calculate velocity limits
  1141.     MaxSpeedX = ScaleWidth * 15! / 800
  1142.     MaxSpeedY = ScaleWidth * 15! / 600
  1143.  
  1144.     ' initial velocities
  1145.     vy1 = 0: vx1 = 0
  1146.  
  1147.     ' initial offset
  1148.     x1 = 0: y1 = 0
  1149.  
  1150.     Direction = Rnd * 2: If Direction > 1 Then Direction = 0
  1151.  
  1152.   Else  ' put run code here
  1153.  
  1154.     DC = Original.hDC
  1155.  
  1156.     If Direction Then
  1157.         ' do vertical scroll
  1158.         BitBlt hDC, 0, y1, ScaleWidth, ScaleHeight - y1, DC, 0, 0, &HCC0020
  1159.         BitBlt hDC, 0, 0, ScaleWidth, y1, DC, 0, ScaleHeight - y1, &HCC0020
  1160.     Else
  1161.         ' do horizontal scroll
  1162.         BitBlt hDC, x1, 0, ScaleWidth - x1, ScaleHeight, DC, 0, 0, &HCC0020
  1163.         BitBlt hDC, 0, 0, x1, ScaleHeight, DC, ScaleWidth - x1, 0, &HCC0020
  1164.     End If
  1165.  
  1166.     'determine new acceleration
  1167.     ax1 = Rnd - .5
  1168.     ay1 = Rnd - .5
  1169.             
  1170.     'calculate new velocity
  1171.     vx1 = (vx1 + ax1): If Abs(vx1) > MaxSpeedX Then vx1 = 0: ax1 = 0
  1172.     vy1 = (vy1 + ay1): If Abs(vy1) > MaxSpeedY Then vy1 = 0: ay1 = 0
  1173.  
  1174.     'find new roll amount
  1175.     x1 = x1 + vx1
  1176.     If x1 > ScaleWidth Then
  1177.         x1 = x1 - ScaleWidth
  1178.     Else
  1179.         If x1 < 0 Then
  1180.             x1 = x1 + ScaleWidth
  1181.         End If
  1182.     End If
  1183.             
  1184.     y1 = y1 + vy1
  1185.     If y1 > ScaleHeight Then
  1186.         y1 = y1 - ScaleHeight
  1187.     Else
  1188.         If y1 < 0 Then
  1189.             y1 = y1 + ScaleHeight
  1190.         End If
  1191.     End If
  1192.             
  1193.   End If
  1194.  
  1195. End Sub
  1196.  
  1197. Sub Scrape ()
  1198.  
  1199.   ' bitblt's with various patterns, dragging them
  1200.   ' across the screen randomly
  1201.  
  1202.   ' if first time then initialize
  1203.   If PlotInit = False Then
  1204.     
  1205.     ' start with original screen
  1206.     Picture = Original.Image
  1207.     
  1208.     PlotInit = True
  1209.  
  1210.     'determine initial position of line
  1211.     x1 = Rnd * ScaleWidth
  1212.     y1 = Rnd * ScaleHeight
  1213.     x2 = Rnd * ScaleWidth
  1214.     y2 = Rnd * ScaleHeight
  1215.     
  1216.     'Calculate velocity limits
  1217.     MaxSpeedX = ScaleWidth * 15! / 800
  1218.     MaxSpeedY = ScaleWidth * 15! / 600
  1219.  
  1220.     BoxHeight = 400 * Rnd ^ 3 + 20
  1221.     BoxWidth = (400 * Rnd ^ 3 + 20) * (8# / 6#)
  1222.  
  1223.     ' zero initial velocity
  1224.     vx1 = 0: vy1 = 0
  1225.  
  1226.     ' choose scrape type at random
  1227.     i = Rnd * 16
  1228.     Select Case i
  1229.  
  1230.         Case 0: Pattern = &H42 'Black Out
  1231.                 Locked = True
  1232.         Case 1: Pattern = &HFF0062 'White Out
  1233.                 Locked = True
  1234.         Case 2: Pattern = &HBB0226 'MergePaint
  1235.                 Locked = False
  1236.         Case 3: Pattern = &HCC0020 'Source Copy
  1237.                 Locked = False
  1238.         Case 4: Pattern = &HCC0020 'Source Copy
  1239.                 Locked = True
  1240.                 Picture = LoadPicture() ' start with blank screen
  1241.         Case 5: Pattern = &H330008 'Not source copy
  1242.                 Locked = True
  1243.         Case 6: Pattern = &H330008 'Not source copy
  1244.                 Locked = False
  1245.         Case 7: Pattern = &H1100A6 'not source erase
  1246.                 Locked = True
  1247.         Case 8: Pattern = &H1100A6 'not source erase
  1248.                 Locked = False
  1249.         Case 9: Pattern = &H440328 'source erase
  1250.                 Locked = True
  1251.         Case 10: Pattern = &H440328 'source erase
  1252.                 Locked = False
  1253.         Case 11: Pattern = &H660046 'source invert
  1254.                 Locked = True
  1255.         Case 12: Pattern = &H660046 'source invert
  1256.                 Locked = False
  1257.         Case 13: Pattern = &H8800C6 'source and
  1258.                 Locked = False
  1259.         Case 14: Pattern = &HEE0086 'source paint
  1260.                 Locked = False
  1261.         Case Else: Pattern = &H550009 'Invert Destination
  1262.                 Locked = True
  1263.  
  1264.     End Select
  1265.   Else  ' put run code here
  1266.  
  1267.         ' do locking if necessary
  1268.         If Locked Then
  1269.             x2 = x1: y2 = y1
  1270.         Else 'do offset
  1271.             x2 = x1 + BoxWidth: If x2 + BoxWidth > ScaleWidth Then x2 = 0
  1272.             y2 = y1 + BoxHeight: If y2 + BoxHeight > ScaleHeight Then y2 = 0
  1273.         End If
  1274.  
  1275.         'BitBlt Box at x1,y1
  1276.         DC = Original.hDC
  1277.         BitBlt hDC, x1, y1, BoxWidth, BoxHeight, DC, x2, y2, Pattern
  1278.         
  1279.         'determine new acceleration
  1280.         ax1 = Rnd - .5
  1281.         ay1 = Rnd - .5
  1282.             
  1283.         'calculate new position
  1284.         x1 = x1 + vx1
  1285.         y1 = y1 + vy1
  1286.             
  1287.         'calculate new velocity
  1288.         vx1 = (vx1 + ax1): If Abs(vx1) > MaxSpeedX Then vx1 = 0: ax1 = 0
  1289.         vy1 = (vy1 + ay1): If Abs(vy1) > MaxSpeedY Then vy1 = 0: ay1 = 0
  1290.             
  1291.         'check if off screen
  1292.         If (x1 > ScaleWidth - BoxWidth) Then
  1293.             'change direction
  1294.             vx1 = -Abs(vx1)
  1295.         ElseIf (x1 < 0) Then
  1296.             'change direction
  1297.             vx1 = Abs(vx1)
  1298.         End If
  1299.  
  1300.         If (y1 > ScaleHeight - BoxHeight) Then
  1301.             'change direction
  1302.             vy1 = -Abs(vy1)
  1303.         ElseIf (y1 < 0) Then
  1304.             'change direction
  1305.             vy1 = Abs(vy1)
  1306.         End If
  1307.  
  1308.     
  1309.     
  1310.   End If
  1311.  
  1312.  
  1313. End Sub
  1314.  
  1315. Sub Squiggles ()
  1316.  
  1317.   ' draw multiple squiggles on the screen.
  1318.   ' each squiggle is assign a random color at the
  1319.   ' start, then the head travels randomly and the
  1320.   ' tail is erased
  1321.  
  1322.   Dim i As Integer, j As Integer, k As Integer, ii As Integer, N As Integer
  1323.     Static SquigNumb As Integer
  1324.     Static SquigLen As Integer
  1325.     Static EndPointer As Integer, StartPointer As Integer
  1326.  
  1327.   ' if first time then initialize
  1328.   If PlotInit = False Then
  1329.     
  1330.     PlotInit = True
  1331.     Cls
  1332.     Forecolor = QBColor(15)
  1333.  
  1334.     SquigNumb = Rnd * 10 + 10
  1335.     SquigLen = Rnd * 100 + 50
  1336.  
  1337.     'Allocate Memory
  1338.     ReDim x1da(SquigLen, SquigNumb)  As Integer
  1339.     ReDim y1da(SquigLen, SquigNumb)  As Integer
  1340.     ReDim x1sa(SquigNumb) As Single
  1341.     ReDim y1sa(SquigNumb) As Single
  1342.     ReDim vx1sa(SquigNumb) As Single
  1343.     ReDim vy1sa(SquigNumb) As Single
  1344.     ReDim ax1sa(SquigNumb) As Single
  1345.     ReDim ay1sa(SquigNumb) As Single
  1346.     ReDim Colors(SquigNumb) As Long
  1347.     
  1348.     Pointer = 1
  1349.  
  1350.     'Print "Clearing Array"
  1351.     For j = 1 To SquigNumb
  1352.         'determine initial position of line
  1353.         x1sa(j) = Rnd * ScaleWidth
  1354.         y1sa(j) = Rnd * ScaleHeight
  1355.  
  1356.         For i = 1 To SquigLen
  1357.             x1da(i, j) = x1sa(j)
  1358.             y1da(i, j) = y1sa(j)
  1359.         Next i
  1360.  
  1361.     Next j
  1362.     
  1363.     'find background color
  1364.     m = QBColor(0)
  1365.  
  1366.     ' use rgb function to get colors
  1367.     For ii = 1 To SquigNumb
  1368.         i = Rnd * 255: If i > 255 Then i = 255
  1369.         j = Rnd * 255: If j > 255 Then j = 255
  1370.         k = Rnd * 255: If k > 255 Then k = 255
  1371.         Colors(ii) = RGB(i, j, k)
  1372.     Next ii
  1373.  
  1374.     'Calculate velocity limits
  1375.     MaxSpeedX = ScaleWidth * 15! / 800
  1376.     MaxSpeedY = ScaleWidth * 15! / 600
  1377.  
  1378.   Else  ' put run code here
  1379.   
  1380.  
  1381.         'find where tail line went to
  1382.         If Pointer < SquigLen Then
  1383.             EndPointer = Pointer + 1
  1384.         Else
  1385.             EndPointer = 1
  1386.         End If
  1387.  
  1388.         'find where new line goes
  1389.         If Pointer > 1 Then
  1390.             StartPointer = Pointer - 1
  1391.         Else
  1392.             StartPointer = SquigLen
  1393.         End If
  1394.  
  1395.         For j = 1 To SquigNumb
  1396.         
  1397.             'Erase tails of squigles
  1398.             Line (x1da(Pointer, j), y1da(Pointer, j))-(x1da(EndPointer, j), y1da(EndPointer, j)), m
  1399.  
  1400.             'Save new points
  1401.             x1da(Pointer, j) = x1sa(j)
  1402.             y1da(Pointer, j) = y1sa(j)
  1403.  
  1404.             'Draw front of Squigles
  1405.             Line (x1da(StartPointer, j), y1da(StartPointer, j))-(x1da(Pointer, j), y1da(Pointer, j)), Colors(j)
  1406.  
  1407.         Next j
  1408.  
  1409.         'Move pointer to next item
  1410.         Pointer = Pointer + 1
  1411.         If Pointer > SquigLen Then
  1412.             Pointer = 1
  1413.         End If
  1414.  
  1415.         For j = 1 To SquigNumb
  1416.  
  1417.             'determine new acceleration
  1418.             ax1sa(j) = Rnd * 4 - 2
  1419.             ay1sa(j) = Rnd * 4 - 2
  1420.  
  1421.             'calculate new position
  1422.             x1sa(j) = x1sa(j) + vx1sa(j)
  1423.             y1sa(j) = y1sa(j) + vy1sa(j)
  1424.  
  1425.             'calculate new velocity
  1426.             vx1sa(j) = (vx1sa(j) + ax1sa(j)): If Abs(vx1sa(j)) > 20 Then vx1sa(j) = 0: ax1sa(j) = 0
  1427.             vy1sa(j) = (vy1sa(j) + ay1sa(j)): If Abs(vy1sa(j)) > 20 Then vy1sa(j) = 0: ay1sa(j) = 0
  1428.  
  1429.             'check if off screen
  1430.             If (x1sa(j) > ScaleWidth) Then
  1431.                 x1sa(j) = ScaleWidth
  1432.                 'change direction
  1433.                 vx1sa(j) = -Abs(vx1sa(j))
  1434.             ElseIf (x1sa(j) < 0) Then
  1435.                 x1sa(j) = 0
  1436.                 'change direction
  1437.                 vx1sa(j) = Abs(vx1sa(j))
  1438.             End If
  1439.  
  1440.             If (y1sa(j) > ScaleHeight) Then
  1441.                 y1sa(j) = ScaleHeight
  1442.                 'change direction
  1443.                 vy1sa(j) = -Abs(vy1sa(j))
  1444.             ElseIf (y1sa(j) < 0) Then
  1445.                 y1sa(j) = 0
  1446.                 'change direction
  1447.                 vy1sa(j) = Abs(vy1sa(j))
  1448.             End If
  1449.  
  1450.         Next j
  1451.     
  1452.   End If
  1453.  
  1454. End Sub
  1455.  
  1456. Sub Tick_Timer ()
  1457.  
  1458.     ' check elapsed time to see if need to change type of plot
  1459.     ' also check if past midnight
  1460.     CurrentTime = Timer
  1461.     If (CurrentTime > MaxTime) Or (LastTime > CurrentTime) Then
  1462.         MaxTime = MaxChangeMinutes * 60 + CurrentTime ' calculate time in seconds
  1463.  
  1464.         ' get new plottype, but make sure it is not
  1465.         ' the same as the current one
  1466.         Do
  1467.             i = Rnd * (MaxPlotType + 1) 'choose next one at random
  1468.             If i > MaxPlotType Then i = 0
  1469.         Loop While (i = PlotType)
  1470.         PlotType = i
  1471.  
  1472.         PlotInit = False
  1473.                 
  1474.         Picture = LoadPicture()
  1475.  
  1476.         BackGround.AutoRedraw = False
  1477.  
  1478.         ClearArrays 'set arrays to zero size when not needed
  1479.  
  1480.         'reset tick rate
  1481.         Tick.Interval = 50
  1482.  
  1483.     End If
  1484.     
  1485.     LastTime = CurrentTime
  1486.  
  1487.     Select Case PlotType
  1488.  
  1489.         Case 0: Squiggles
  1490.         Case 1: Kalied2
  1491.         Case 2: Polygons
  1492.         Case 3: Circles
  1493.         Case 4: Kalied
  1494.         Case 5: Lines
  1495.         Case 6: Roll
  1496.         Case 7: Patch
  1497.         Case 8: Puzzle
  1498.         Case 9: Scrape
  1499.         Case 10: Scrape ' will be used twice as often
  1500.         Case Else: PlotType = 0
  1501.  
  1502.     End Select
  1503.  
  1504. End Sub
  1505.  
  1506.